User loginNavigation |
LtU Forum, Site Discussion[ANN] Scala-2The Scala language fuses object-oriented and functional programming while staying completely interoperable with Java. It is compiled to JVM class files, subclassing is allowed both ways between Java and Scala classes, and no glue code needs to be written by users. Scala also adds several important and convenient constructs, such as: - mixin composition with traits, The second major version of Scala is now publicly available. This version adds some new constructs to the language and simplifies some idioms (http://scala.epfl.ch/docu/scala2.html). There are also the following new tools: - a new `scalac' compiler, which is completely written in Scala - a new `scalaint' interpreter shell, which is integrated with the compiler and which drops most restrictions of the previous version. - a new Eclipse plugin. See http://scala.epfl.ch/docu/eclipse/index.html - a new tool `sbaz' to manage and distribute Scala packages. See http://scala.epfl.ch/downloads/sbaz.html This implementation runs on the Java VM, JDK 1.4 or 1.5. An automatic installer is available for Windows, MacOS X, Linux, Solaris, and most other operating systems. For further information and downloads, please visit: http://scala.epfl.ch Class hierarchies and OntologiesI've recently been looking at high-level ontologies, such as CYC and SUMO for a project I'm working on. Clearly, there is a connection between techniques used for organising class hierarchies and those used for organising ontologies (class hierarchies are ontologies, at least superficially). Going further, there seems to be an overlap between languages' standard class libraries and these high-level "common sense" ontologies. Each describes quite general concepts like "objects", "processes", "sets" and "classes", and then provide more specific concepts for particular domains. With RDF and OWL becoming popular (or not?), I wonder if there will be a merging between these two similar areas. Are there any languages that come with a standard ontology? Are there languages whose tools for modelling class hierarchies more closely resemble those of ontology authoring tools? For instance, supporting more than just "subtype" and "instance" relations (i.e., more like first-order logic or a description logic). Haskell's type-classes come to mind. Is there any restriction on the kinds of relations between types that can be expressed by type-classes? Are there techniques that can be applied to type/class-level organisation from ontology modelling? "Semi-complete" Boolean Evaluation?We have a new apprentice programmer here at work, and I was trying to explain to her the difference between complete and lazy boolean evaluation, and why she should be always be mindful of side effects when it's turned on or off. While she grasped the concept well enough, she confounded me in asking why the distinction exists in the first place (seeing as it creates side effects). This got me thinking whether "semi-complete" boolean evaluation would be an asset to an imperative PL. For example:
In scenario A, completely lazy evaluation is the preferred way, because the expressions being evaluated are boolean variables, pure and simple, and the compiler should automatically enable lazy evaluation for that conditional. In scenario B, someObjectInstance.someBoolMethod might do some internal processing that we want regardless, yet the ordering of the expressions determines that that might not happen if BoolVar is false and the expression is evaluated "lazily". This in some ways spoils the pure nature of boolean logic because expression order becomes important in determining the result, and switching lazy eval on/off becomes an issue. Similarly, in scenario C, the same issues apply. I realise that these issues can be avoided by reordering or splitting the conditional statements into multiple if/then's, but what about if the language, as a rule, ALWAYS evaluated expressions, if they were methods or function calls, regardless of where they occured in the conditional. For scenario B, for example, that would mean that even if boolVar was false, the someObjectInstance.someBoolMethod still gets called, except that the conditional statements below get skipped . The overall effect would be that the language always presents complete evaluation to the programmer (who then does not have to factor in expression order), but can benefit from lazy evaluation if the compiler deems it appropriate. It could perhaps also be possible to have a language construct to force the lazy evaluation, for example:
or
or suchlike, with the compiler giving appropriate warnings where neccessary. I understand that allowing expression order to be an issue, is A Bad Thing regardless, to be avoided by careful code habits. I am also not neccessarily advocating the "semi-lazy" method, as I recognise how it introduces a new way of creating undesirable side effects (namely what happens inside the called methods), but I am nevertheless interested in hearing your comments on the topic. Regards, The R ProjectOne of my best friends is a Ph.D. student in a well-respected geology department, and an avid R user. He informs me that the programming language "R" is highly fashionable in his department, and is increasingly popular across his field. I mention this because R encourages functional programming, and I have not heard it mentioned on LtU. Here is a quote from the language manual:
Here is another quote from the FAQ:
The upshot is that "S" is dynamically scoped while "R" is lexically scoped. I applaud R for getting this right, but the FAQ makes an interesting counterpoint that I paraphrase here:
Other than scope, R tries to be as close to S as possible. I'll end with two amusing remarks from the introduction:
Enjoy. Type Inference in Object Oriented LanguagesIs it possible to do type inference of an object oriented language (such as Java) without any type annotations? I've never seen it done and I'm curious about why that is. During my limited exposure (to type inference in general) I've been taught that it is possible to do type inference of rank 1 polymorphic functions but the general case (rank 2 and up) is undecidable without type annotations. How does this relate to the type of polymorphism used in object oriented languages? Message Passing vs. Multi-Methods; Mixing the two?Even though message passing can be thought of as a special case of the generic functions approach, there still seems to be something appealing about grouping procedure implementations and their shared data into logical units as in Smalltalk. I understand that polymorphic dispatch need not be conflated with program modularity / encapsulation, but for some reason it still feels like a good idea to me. I looked around this afternoon for a good discussion of multi-methods vs. message passing and came up empty, so I'm wondering if anyone could point me to one or share their thoughts on the issue. I am interested in writing a lispy scripting language that integrates with the Apple's Cocoa environment, which is based on Smalltalk and therefore hardcore message-passing based. I would like a seamless connection into that world from this language. But I also want the power of multi-methods. I am imagining a language in which first-class namespaces could be blended with the Smalltalk approach to objects, exposing methods that respond to messages. But within these namespaces multi-methods could be used when they seemed appropriate. Therefore, in the large, the program would be assembled out of modules that resembled Smalltalk objects, but the implementation of methods exposed by these modules could have a lispier style. This is all very vague I know... and there's the obvious question of where multi-methods would belong. Any ideas? A virtual class calculusReading Martin Oderski's paper Scalable Component Abstractions, I ran across citations to the languages CeasarJ and Gbeta, both realizing a concept called virtual classes. This concept is explained, and a calculus given in the paper A Virtual Class Calculus by Erik Ernst, Klaus Ostermann, and William R. Cook. Virtual classes are class-valued attributes of objects. Like virtual methods, virtual classes are defined in an object's class and may be redefined within subclasses. They resemble inner classes, which are also defined within a class, but virtual classes are accessed through object instances, not as static components of a class. When used as types, virtual classes depend upon object identity -- each object instance introduces a new family of virtual class types. Virtual classes support large-scale program composition techniques, including higher-order hierarchies and family polymorphism. The original definition of virtual classes in BETA left open the question of static type safety, since some type errors were not caught until runtime. Later the languages Caesar and gbeta have used a more strict static analysis in order to ensure static type safety. However, the existence of a sound, statically typed model for virtual classes has been a long-standing open question. This paper presents a virtual class calculus, VC, that captures the essence of virtual classes in these full-fledged programming languages. The key contributions of the paper are a formalization of the dynamic and static semantics of VC and a proof of the soundness of VC. logic/constraint/relational programming?Lately I have been coming across a set of ideas which seem to be related: Is there a comprehensive introduction to all of the above? I would like to know the meaning of the terms mentioned above and, if possible, how to implement them. Krishnamurthi's book Programming Languages: Application and Interpretation mentions prolog, but doesn't show how to implement those ideas in scheme. The Reasoned Schemer is not easy to follow (due to the style of the book). It is not the kind of book one can read once a week after work. There are a few constraint logic books on Amazon, but I obviously don't even know enough to understand if they are good introductions. There is a lot of talk of how functional programs operate at a higher level of abstraction (compared to imperative programs)...don't these logic/constraint programs operate at an even higher abstraction? Lisp defenders always make sure newbies understand that Lisp is not just for AI. Is the same true of prolog? I have read that logic programs are not very efficient; however, if they are related to relational databases (as claimed somewhere), then can't an 'index' be added to a list of 'facts' to make sure logic program's operation is as efficient as any other program? I'm just trying to get a sense of the field, its benefits, its pitfalls and reasons why it is not so popular. Thanks. ObjectiveCLIPS UpdatedObjectiveCLIPS, a programming environment specifically designed for Cocoa, the native Mac OS X object system, has been updated to version 1.7. The new release includes a number of significant performance improvements along with a new execution trace feature that provides extensive logging of trace information during development. ObjectiveCLIPS integrates the popular NASA-developed CLIPS expert system shell with Apple's Core Data technology and F-Script, allowing the creation of intelligent Cocoa applications with persistent object models and complex business rules. Developers can easily embed ObjectiveCLIPS in their application and take advantage of its powerful inference engine and associated tools to implement their application logic. ObjectiveCLIPS unifies CLIPS facts with Core Data Objective-C objects, and allows for the manipulation of these objects with the Cocoa-based F-Script language in rules. By bringing the latest innovations in Mac OS X and object-oriented scripting together with the power of the CLIPS artificial intelligence environment, ObjectiveCLIPS provides a unique foundation for building smart Mac OS X applications. ObjectiveCLIPS is open source software. It can be downloaded from http://www.ObjectiveCLIPS.com help from language peopleHi all, bonjour: return {hello, namaste} eval hellothisisatextstringbonjursomemoreenglishtext output: {hellothisisatextstringhellosomemoreenglishtext, hellothisisatextstringnamastesomemoreenglishtext} Perl regular expressions would've been sufficient, nice and clean, but I can't return lists like above. Just scratching my head, there may be something obivous I am missing. |
Browse archives
Active forum topics |
Recent comments
10 weeks 1 day ago
10 weeks 1 day ago
10 weeks 2 days ago
10 weeks 2 days ago
10 weeks 6 days ago
10 weeks 6 days ago
11 weeks 11 hours ago
11 weeks 15 hours ago
11 weeks 16 hours ago
11 weeks 17 hours ago